package com.daxia.ogmall.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * DecorateNoteDetail
 */
@Entity
@Table(name = "decoratenotedetail") 
public class DecorateNoteDetail extends BaseModel {
	/**
	 * id
	 */
	@Id
	@GeneratedValue
	@Column(name = "id")
    private Long id;
	/**
	 * 图片
	 */
	@Column(name = "images")
    private String images;
	
	@Transient
	private String[] imageArr;
	/**
	 * 详情内容
	 */
	@Column(name = "details")
    private String details;
	/**
	 * 软装笔记类型
	 */
	@Column(name = "type")
    private Integer type;
	/**
	 * 软装笔记
	 */
	@ManyToOne
	@JoinColumn(name = "decorateNote_id")
    private DecorateNote decorateNote;

	/**
	 * 创建时间
	 */
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "createTime")
    private Date createTime;
	
	public Long getId() {
    	return id;
    }
	
    public void setId(Long id) {
    	this.id = id;
    }
	
	public String getImages() {
    	return images;
    }
	
    public void setImages(String images) {
    	this.images = images;
    }
	
	public String getDetails() {
    	return details;
    }
	
    public void setDetails(String details) {
    	this.details = details;
    }
	
	public Integer getType() {
    	return type;
    }
	
    public void setType(Integer type) {
    	this.type = type;
    }
	
	public DecorateNote getDecorateNote() {
    	return decorateNote;
    }
	
    public void setDecorateNote(DecorateNote decorateNote) {
    	this.decorateNote = decorateNote;
    }

	public Date getCreateTime() {
    	return createTime;
    }
	
    public void setCreateTime(Date createTime) {
    	this.createTime = createTime;
    }

	public String[] getImageArr() {
		if (StringUtils.isBlank(getImages())) {
			return new String[] {};
		}
		List<String> list = new ArrayList<String>();
		for (String string : getImages().split(",")) {
			list.add(string);
		}
		return list.toArray(new String[]{});
	}

	public void setImageArr(String[] imageArr) {
		this.imageArr = imageArr;
	}
    
}
